import { createRouter, createWebHashHistory, RouteRecordRaw, } from 'vue-router'


const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/common/Login.vue'),
        meta: {
            isShow: true
        },
    },
    {
        path: '/serchDetail',
        name: 'serchDetail',
        component: () => import('@/views/common/serchDetail.vue'),
        meta: {
            isShow: true
        },
    },
    {
        path: '/layout',
        name: 'layout',
        component: () => import('@/views/layout/index.vue'),
        children:[
            {
                path: '/home',
                name: 'home',
                component: () => import('@/views/common/Home.vue'),
               
          
            },
            {
                path: '/search',
                name: 'search',
                component: () => import('@/views/common/Search.vue'),
              
            },
            {
                path: '/userPage',
                name: 'userPage',
                component: () => import('@/views/common/userPage.vue'),
        
            },
        ],
    },
    // {
    //     path: '/demo1',
    //     name: 'demo1',
    //     component: () => import('@/views/work/workOrder/demo1.vue'),
  
    // },
    // {
    //     path: '/demo2',
    //     name: 'demo2',
    //     component: () => import('@/views/work/workOrder/demo2.vue'),

    // },
    // {
    //     path: '/demo3',
    //     name: 'demo3',
    //     component: () => import('@/views/work/workOrder/demo3.vue'),

    // },
    {
        path: '/work',
        name: 'work',
        component: () => import('@/views/work/index.vue'),
        children:[
            {
                path: 'demo1',
                name: 'demo1',
                component: () => import('@/views/work/workOrder/demo1.vue'),
          
            },
            {
                path: 'demo2',
                name: 'demo2',
                component: () => import('@/views/work/workOrder/demo2.vue'),
        
            },
            {
                path: 'demo3',
                name: 'demo3',
                component: () => import('@/views/work/workOrder/demo3.vue'),
        
            },
        ],
    },
  ]
  

  const router = createRouter({
    history:createWebHashHistory(),
    routes,
    // scrollBehavior(to, from, savedPosition) {
    //     if (savedPosition) {
    //         console.log('savedPosition :>> ', savedPosition);
    //         return savedPosition
    //     } else {
    //         console.log('未进入');
    //         return { top:0} 
    // }
    // }
  })

// router.beforeEach(async (to, from, next) => { 
//     // console.log(to.meta.isShow,'to.meta.isShow')
//     // if (to.meta.isShow) {
//     //     next('/login')
//     // } else {
//     //     next()
//     // }
// })

export default router